*****------------------------------------------------******
***** Paper: Revisiting the Impact of Modernization on Support for Women Politicians: The Role of Women’s Political Empowerment  ----****
***** Manuscript empirics: All Tables, figures and numbers  ------------------------*******
**** Created by: Anja Neundorf, University of Glasgow
**** Date created: 24/02/2020
**** Last updated: 16/11/2021


***-----------------------------------------------------------*****
***-----------------------------------------------------------*****
*Set-up do-file

clear all
set more off
set scheme plottig 

cd "/Users/aneundorf/Dropbox/Project_Regimes/Analysis/Gender/" // need to change path 


***-----------------------------------------------------------*****
***-----------------------------------------------------------*****
* Coverage data
use "Data/MergedData_Gender.dta", clear

bys data: tab year if women_lead!=.
tab year if women_lead!=.

bys data: tab country_name if women_lead!=.




***-----------------------------------------------------------*****
***-----------------------------------------------------------*****
* FIGURE 1: Women’s descriptive legislative representation and empowerment by regime type.

use "Data/MacroData_Gender_long.dta", clear

pwcorr democ_dum v2x_polyarchy modern_new v2x_gender2 v2lgfemleg e_migdppcln e_migdppc
sum democ_dum modern_new v2x_gender2 v2lgfemleg e_migdppcln e_migdppc 

twoway(kdensity v2x_gender2  if democ_dum==0 & year>1919, lp(dash) lw(medthick) lc(gs6)) ///
(kdensity v2x_gender2  if democ_dum==1 & year>1919, lp(solid) lw(medthick) lc(black)), ///
xlabel(0(.2)1 ,  angle(horizontal)labsize(medsmall )) ///
ylabel(,  angle(horizontal)labsize(medsmall)) ///
	xtitle("Women political empowerment (0=none; 1=full)", size(medium))  ///
 title("A. Women political empowerment", size(medlarge)) legend(off) note("R=0.58", pos(11) ring(0) size(medium)) ytitle("Density", size(medium)) ///
	 scheme(plottig) graphregion(fcolor(white)) name(inst, replace)


twoway(kdensity v2lgfemleg  if democ_dum==0 & year>1919, lp(dash) lw(medthick) lc(gs6)) ///
(kdensity v2lgfemleg  if democ_dum==1 & year>1919, lp(solid) lw(medthick) lc(black)), ///
xlabel(,  angle(horizontal)labsize(medsmall)) ///
	ylabel(,  angle(horizontal)labsize(medsmall)) ///
xtitle("Lower chamber female legislators", size(medium))  ///
ytitle("Density", size(medium)) ///
 title("B. Lower chamber female legislators", size(medlarge)) legend(lab(2 "Democracy") lab(1 "Autocracy") order(1 2) region(lcolor(white))pos(1) ring(0) row(2) size(medium)) note("R=0.18", pos(11) ring(0) size(medium))  ///
	 scheme(plottig) graphregion(fcolor(white)) name(legis, replace)
	 

graph combine inst  legis, graphregion(fcolor(white)) 
graph save Graph "Graphs/Regime_FemaleEmpower.gph",  replace
graph export "Graphs/Regime_FemaleEmpower.pdf",  replace


***-----------------------------------------------------------*****
***-----------------------------------------------------------*****
* FIGURE 2:  Modernization and female empowerment
use "Data/MacroData_Gender_long.dta", clear

bys democ_dum: pwcorr  modern_new v2x_gender2 v2lgfemleg 

twoway(scatter v2x_gender2 modern_new if democ_dum==0 & year>1919, ms(oh) mc(gs8)) (scatter v2x_gender2 modern_new if democ_dum==1 & year>1919, ms(X) mc(black)) (lfit v2x_gender2 modern_new if democ_dum==0 & year>1919, lc(gs7)  lw(medthick)) (lfit v2x_gender2 modern_new if democ_dum==1 & year>1919, lc(black) lw(medthick)) , scheme(plottig) graphregion(fcolor(white)) legend(lab(2 "Democracy (R=0.55)") lab(1 "Autocracy (R=0.70)") order(1 2) region(lcolor(white))pos(11) ring(0) row(2) size(mall)) ytitle("Women political empowerment (0=none; 1=full)", size(medium))  xtitle("Modernization index (0=none; 1=full)", size(medium))  name(mod_inst, replace) //title("A. Institutional female empowerment", size(medlarge)) 
graph save  "Graphs/Modern_FemaleEmpower.gph",  replace
graph export "Graphs/Modern_FemaleEmpower.pdf",  replace



***-----------------------------------------------------------*****
***-----------------------------------------------------------*****
* FIGURE 3: Power index + modernisation
use "Data/MacroData_Gender.dta", clear

sort  country year
 merge  country   using "Data/Country_cover.dta"

 tab country if indata==1
 drop if indata!=1
 tab country_name

 sort country year 
 keep if country_name=="Argentina" | country_name=="Botswana" | country_name=="Brazil"  | country_name=="Chile" | country_name=="China" | country_name=="Costa Rica" |country_name=="Germany" | country_name=="Hungary" |  country_name=="India" | country_name=="Iran" |country_name=="Jordan" | country_name=="Thailand" | country_name=="Turkey" | country_name=="Libya" |country_name=="Namibia" | country_name=="Paraguay"  | country_name=="Russia" | country_name=="Rwanda" |country_name=="Saudi Arabia" | country_name=="Singapore" | country_name=="South Africa" | country_name=="Egypt" |country_name=="Spain" | country_name=="Sweden"   | country_name=="Tanzania" |country_name=="Japan"  | country_name=="United States of America" |country_name=="Serbia" | country_name=="South Korea" | country_name=="Indonesia"
 
twoway (line modern_new year if year>1989 & indata==1, lw(medthick)) (line v2x_gender2  year if year>1989 & indata==1, lp(shortdash)) ///
	,  by(country, note(""))  ///
	ytitle("Women pol. empower./Modernization" , size(medsmall)) xtitle("", size(tiny) margin(2 2 2 2)) ///
	ylabel(0(0.5)1, nogrid labsize(medium) format(%9.1f) angle(hor)) legend(off) ///
	xlabel(1990(10)2015,labsize(large)) ///
	legend(lab(1 "Modernization (0=none; 1=fullest)") lab(2 "Women pol. empowerment (0=none; 1=full)") ///
	r(2) order(1 2) region(lcolor(white))) ///
	scheme(s2mono) graphregion(fcolor(white))
	graph save Graph "Graphs//Macro_Gender_Regime+Modern.gph",  replace
	graph export "Graphs/Macro_Gender_Regime+Modern.png",  replace


	collapse v2x_gender2 modern_new, by(country year)
	tsset country year 
	
	xtsum v2x_gender2 modern_new if year>1993
*__________________________________________________________________________________________

***-----------------------------------------------------------*****
***-----------------------------------------------------------*****
*Table 1 - Gender
use "Data/MergedData_Gender.dta", clear

 sum age women_lead birth coh5_modern_new coh5_v2x_gender modern_new_1 v2x_gender_1 female educ_combi working religion  age_democ
 
pwcorr coh5_modern_new modern_new_1 coh5_v2x_gender v2x_gender_1
 
capture log close 
log using "Results/results_gender_Jul2021", replace 
tab women_lead
tab year if women_lead!=.


	reg  women_lead age  i.data i.year if age>=20, cluster(country)
	
est clear

capture erase "Results/results_Gender_Jul2021_OLS_main.xls"
capture erase "Results/results_Gender_Jul2021_OLS_main.txt"

*polint
foreach var of varlist women_lead   	{
set more off

*estimates clear

	*M1: Indivdual controls
	reg  `var' modern_new_1 i.country i.data i.year
	estat ic
	estimates store M1a
	set more off
		outreg2  using "Results/results_Gender_Jul2021_OLS_main.xls", ///
			bracket bdec(3) sdec(3) append
	
	*M1a: Indivdual controls + period controls
	reg  `var'   v2x_gender2_1 i.country i.data i.year 

	estimates store M1b
		outreg2  using "Results/results_Gender_Jul2021_OLS_main.xls", ///
			bracket bdec(3) sdec(3) append

	*M2: Indivdual + period controls + Modernization	
	reg  `var' age  modern_new_1 i.female i.educ_combi i.working  i.religion  democ_dum  i.country i.data i.year
	estimates store M2a
			outreg2  using "Results/results_Gender_Jul2021_OLS_main.xls", ///
			bracket bdec(3) sdec(3)  append

		*M2b: Indivdual + period controls + Women pol. empowerment
	reg  `var' age  v2x_gender2_1 i.female i.educ_combi i.working  i.religion  democ_dum  i.country i.data i.year
	estat ic
	estimates store M2b
			outreg2  using "Results/results_Gender_Jul2021_OLS_main.xls", ///
			bracket bdec(3) sdec(3)  append
	
	reg  `var' age c.modern_new_1##c.v2x_gender2_1 i.female i.educ_combi i.working i.religion  democ_dum i.country i.data i.year
	estat ic
estimates store M3
		outreg2  using "Results/results_Gender_Jul2021_OLS_main.xls", ///
			bracket bdec(3) sdec(3)  append
	
}


*save "Data/MergedData_Gender_estimates.dta", replace

	
***-----------------------------------------------------------*****
***-----------------------------------------------------------*****
* FIGURE 4: Marginal effects (current context)

*use "Data/MergedData_Gender_estimates.dta",  clear



**-----------
** Current 
sum modern_new_1 v2x_gender_1, d

estimates restore M3

	margins, dydx(modern_new_1) at(v2x_gender2_1=(0.3(0.1)1) ) atmeans
marginsplot, yline(0) ///
	xlabel( , angle(horizontal)labsize(medsmall)) ylabel( , angle(horizontal)labsize(medsmall)) title(" ")  ///
	ytitle("Marginal effect of modernization""on support for female pol. leaders", size(medium)) ///
	xtitle("Women pol. empowerment (0=none; 1=full)", size(medium))  ///
scheme(plottig) graphregion(fcolor(white)) title("B. Marginal effect of modernization (H4)", size(medlarge))  name(marg_modern2, replace)

estimates restore M3

margins, dydx(v2x_gender2_1) at(modern_new_1 =(0.3(0.1)1) ) atmeans
marginsplot, yline(0) ///
	xlabel( , angle(horizontal)labsize(medsmall)) ylabel( , angle(horizontal)labsize(medsmall))  ///
	ytitle("Marginal effect of women pol. empowerment""on support for female pol. leaders", size(medium)) ///
	xtitle("Modernization(0=none; 1=full)", size(medium))  ///
scheme(plottig) graphregion(fcolor(white)) title("A. Marginal effect of women pol. empower. (H3)", size(medlarge))  name(marg_power2, replace)

graph combine  marg_power2 marg_modern2, graphregion(fcolor(white)) name(current, replace)
graph save "Graphs/Margins_Gender_empower_modern_new.gph",  replace
graph export "Graphs/Margins_Gender_empower_modern_new.pdf",  replace	


**** Results on WVS only


foreach var of varlist women_lead   	{
set more off
	*M4: Interaction: Modernization + Women pol. empowerment
	reg  `var' age c.coh5_modern_new##c.coh5_v2x_gender2 i.female i.educ_combi i.working i.religion modern_new_1 v2x_gender2_1  i.country i.data i.year if age>=20 & data==0
	estat ic
	estimates store M4

	*M4: Interaction: Modernization + Women pol. empowerment
	reg  `var' age c.coh5_modern_new coh5_v2x_gender2 c.modern_new_1##c.v2x_gender2_1 i.female i.educ_combi i.working i.religion  i.country i.year if age>=20 & data==0
	estat ic
estimates store M4_2

}
	
	
***-----------------------------------------------------------*****
***-----------------------------------------------------------*****
* FIGURE 5: Marginal effects (current context)
use "Data/MergedData_Gender.dta", clear

est clear

*polint
foreach var of varlist women_lead   	{
set more off

*estimates clear

	*M0: No context 
	set more off
	reg  `var' age  i.country i.data i.year if age>=20  
	estimates store M0
			outreg2  using "Results/results_Gender_Jul2021_OLS_cohort.xls", ///
			bracket bdec(3) sdec(3) append


	*M1: Indivdual controls
	reg  `var' age coh5_modern_new i.country i.data i.year if age>=20
	estat ic
	estimates store M1a
			outreg2  using "Results/results_Gender_Jul2021_OLS_cohort.xls", ///
			bracket bdec(3) sdec(3) append
	
	*M1a: Indivdual controls + period controls
	reg  `var' age  coh5_v2x_gender2  i.country i.data i.year if age>=20

	estimates store M1b
	set more off
				outreg2  using "Results/results_Gender_Jul2021_OLS_cohort.xls", ///
			bracket bdec(3) sdec(3) append

	*M2: Indivdual + period controls + Modernization	
	reg  `var' age coh5_modern_new  i.female i.educ_combi i.working  i.religion democ_dum   i.country i.data i.year if age>=20
	estimates store M2a
				outreg2  using "Results/results_Gender_Jul2021_OLS_cohort.xls", ///
			bracket bdec(3) sdec(3) append

		*M2b: Indivdual + period controls + Women pol. empowerment
	reg  `var' age  coh5_v2x_gender2 i.female i.educ_combi i.working  i.religion  democ_dum  i.country i.data i.year if age>=20
	estat ic
	estimates store M2b
				outreg2  using "Results/results_Gender_Jul2021_OLS_cohort.xls", ///
			bracket bdec(3) sdec(3) append


reg  `var' age c.coh5_modern_new##c.coh5_v2x_gender2 i.female i.educ_combi i.working i.religion democ_dum  i.country i.data i.year if age>=20
	estat ic
	estimates store M3
				outreg2  using "Results/results_Gender_Jul2021_OLS_cohort.xls", ///
			bracket bdec(3) sdec(3) append
}


**-----------
** Figure
sum coh5_modern_new coh5_v2x_gender, d


estimates restore M3

	margins, dydx(coh5_modern) at(coh5_v2x_gender2=(0 0.2 0.4 0.6 0.8 1) ) atmeans
marginsplot, yline(0) ///
	xlabel( , angle(horizontal)labsize(medsmall)) ylabel(-15(5)15 , angle(horizontal)labsize(medsmall)) title(" ")  ///
	ytitle("Marginal effect of modernization""on support for female pol. leaders", size(medium)) ///
	xtitle("Women pol. empowerment (0=none; 1=full)", size(medium))  ///
scheme(plottig) graphregion(fcolor(white)) title("B. Marginal effect of modernization (H4)", size(medlarge))  name(marg_modern, replace)

estimates restore M3
margins, dydx(coh5_v2x_gender2) at(coh5_modern =(0 0.2 0.4 0.6 0.8 1) ) atmeans
marginsplot, yline(0) ///
	xlabel( , angle(horizontal)labsize(medsmall)) ylabel(-15(5)15 , angle(horizontal)labsize(medsmall))  ///
	ytitle("Marginal effect of women pol. empowerment""on support for female pol. leaders", size(medium)) ///
	xtitle("Modernization(0=none; 1=full)", size(medium))  ///
scheme(plottig) graphregion(fcolor(white)) title("A. Marginal effect of women pol. empower. (H3)", size(medlarge))  name(marg_power, replace)

graph combine  marg_power marg_modern, graphregion(fcolor(white)) title("Context: Formative years", size(medlarge)) name(past, replace)
graph save "Graphs/Margins_Gender_empower_modern_new.gph",  replace
graph export "Graphs/Margins_Gender_empower_modern_new.pdf",  replace

